package com.spt.springbootzhsx.controller;

import com.spt.springbootzhsx.entity.Cinema;
import com.spt.springbootzhsx.mapper.CinemaMapper;
import com.spt.springbootzhsx.service.CinemasService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

@RestController
@RequestMapping("/cinema")
public class CinemaController {
    @Autowired
    private CinemasService cinemasService;

    @GetMapping(value="/getCinemaByCname/{cname}")
    public Cinema getCinemaByCinema(@PathVariable("cname") String cname){
        return cinemasService.getCinemaByCname(cname);
    }

    @GetMapping(value="/getCinemaByCid/{cid}")
    public Cinema getCinemaByCid(@PathVariable("cid") Integer cid){
        return cinemasService.getCinemaByCid(cid);
    }

    @GetMapping(value="getAllCinema")
    public ArrayList<Cinema> getAllCinema(){
        return cinemasService.getAllCinema();
    }

    @PostMapping(value="/addCinema")
    public String addCinema(@RequestBody Cinema cinema){
        return cinemasService.addCinema(cinema);
    }

    @PostMapping(value="/updateCinema")
    public String updateCinema(@RequestBody Cinema cinema){
        return cinemasService.updateCinema(cinema);
    }

    @GetMapping(value="/deleteCinema/{cid}")
    public String deleteCinema(@PathVariable("cid") Integer cid){
        return cinemasService.deleteCinema(cid);
    }
}
